﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using SchoolLibrary.Entity.Person;
using SchoolLibrary.Entity;
using SchoolLibrary.DataBase.DAO;

namespace SchoolLibrary.DataBase.Builder
{
    class PupilBuilder : AbstractPersonBuilder
    {
        public override Identity Build(DataRow row)
        {
            Pupil pupil = new Pupil();
            BuildEntity(pupil, row);
            return pupil;            
        }

        protected override void BuildEntity(Identity entity, DataRow row)
        {
            base.BuildEntity(entity, row);
            Pupil pupil = (Pupil)entity;
            long classId = Int32.Parse(row[Pupil.CLASS_ID_COLUMN_NAME].ToString());
            pupil.PupilClass = ClassDAO.getInstance().findById(classId);

        }
    }
}
